package com.itheima.d3_stream;

import java.util.*;
import java.util.stream.Stream;

/*
        目标：掌握Stream流的创建。

        1 单列集合获取Stream流
        2 双列集合获取Stream流
        3 数组获取Stream流
        4 同一种类型多个数据获取Stream流
 */
public class StreamTest2 {
    public static void main(String[] args) {
        // 1、如何获取List集合的Stream流？
        List<String> names = new ArrayList<>();
        Collections.addAll(names, "张三丰", "张无忌", "周芷若", "赵敏", "张强");
        names.stream().forEach(s -> System.out.println(s));

        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("杨过", "小龙女");
        hashMap.put("郭靖", "黄蓉");
        hashMap.put("小明", "小红");
        Set<Map.Entry<String, String>> set = hashMap.entrySet();
        set.stream().forEach(s -> {
            System.out.println(s.getKey() + ":" + s.getValue());
        });


        String[] s = {"小黄", "小黑", "小蓝", "小白"};
        Stream<String> stream = Arrays.stream(s);
        stream.forEach(v -> System.out.println(v));

        Stream<String> st = Stream.of("孙悟空","猪八戒","沙悟净");
        st.forEach(s1 -> System.out.println(s1));
    }
}
